package HomeWork;

import javax.swing.*;

public class Test02 extends JFrame{
    private DouDiZhu douDiZhu = new DouDiZhu();
    private ImageIcon player1 = new ImageIcon("src\\HomeWork\\Images\\Player01.png");
    private ImageIcon player2 = new ImageIcon("src\\HomeWork\\Images\\Player02.png");
    private ImageIcon player3 = new ImageIcon("src\\HomeWork\\Images\\Player03.jpg");

    public Test02(DouDiZhu douDiZhu){
        //设置布局管理器为空
        this.setLayout(null);

        JLabel jLabel01 = new JLabel(player1);
        jLabel01.setBounds(50,200,50,50);

        JLabel jLabel02 = new JLabel(player2);
        jLabel02.setBounds(1300,200,50,50);

        JLabel jLabel03 = new JLabel(player3);
        jLabel03.setBounds(600,600,50,50);

        JLabel jLabelDizhu = new JLabel("地主牌");
        jLabelDizhu.setBounds(550,50,120,30);

        for (int i = 0; i < 17; i++){
            int num01 = (douDiZhu.pokers.get(i).getNum());
            int num02 = (douDiZhu.pokers.get(i).getSuit()) ;
            JLabel jLabel = new JLabel(new ImageIcon("src/HomeWork/Images/" + num01 + "_" + num02 + ".jpg"));


            jLabel.setBounds(130,720-(i * 40),105,150);
            this.add(jLabel);
        }

        for (int i = 17; i < 34; i++){
            int num01 = (douDiZhu.pokers.get(i).getNum());
            int num02 = (douDiZhu.pokers.get(i).getSuit());
            JLabel jLabel = new JLabel(new ImageIcon("src/HomeWork/Images/" + num01 + "_" + num02 + ".jpg"));

            System.out.println("src/HomeWork/Images" + num01 + "_" + num02 + ".jpg");
            jLabel.setBounds(1050,1400-(i * 40),105,150);
            this.add(jLabel);
        }

        for (int i = 34; i < 51; i++){
            int num01 = (douDiZhu.pokers.get(i).getNum());
            int num02 = (douDiZhu.pokers.get(i).getSuit());
            JLabel jLabel = new JLabel(new ImageIcon("src/HomeWork/Images/" + num01 + "_" + num02 + ".jpg"));

            jLabel.setBounds((900- ((i-34) * 40)),700,105,150);
            this.add(jLabel);
        }

        for (int i = 51; i < 54;i ++){
            int num01 = (douDiZhu.pokers.get(i).getNum());
            int num02 = (douDiZhu.pokers.get(i).getSuit());
            JLabel jLabel = new JLabel(new ImageIcon("src/HomeWork/Images/" + num01 + "_" + num02 + ".jpg"));
            jLabel.setBounds(670 - ((i-51) * 130),100,105,150);
            this.add(jLabel);
        }

        this.add(jLabel01);
        this.add(jLabel02);
        this.add(jLabel03);
        this.add(jLabelDizhu);


        //设置标题文字
        this.setTitle("斗地主");
        //设置窗口大小
        this.setSize(1400,1000);
        //设置窗口的关闭策略
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        //设置窗口默认打开的位置居中
        this.setLocationRelativeTo(null);
        //设置窗口显示模式
        this.setVisible(true);


    }
    public void sort(int start,int end){
        for (int i = start; i < end;i ++){
            int num = (douDiZhu.pokers.get(i).getNum()) / 10;
            int num2 = (douDiZhu.pokers.get(i).getNum()) % 10;
            JLabel jLabel = new JLabel(new ImageIcon("img\\" + num + "_" + num2 + ".jpg"));
            jLabel.setBounds(130,520-(i * 30),105,150);
            this.add(jLabel);
        }
    }


    public static void main(String[] args) {
        DouDiZhu douDiZhu = new DouDiZhu();
        douDiZhu.init();
        douDiZhu.shuffle();
        douDiZhu.sendCard();
        new Test02(douDiZhu);
    }
}
